package org.jflame.context.filemanager;

import java.io.FileNotFoundException;
import java.io.IOException;

/**
 * 文件访问通用异常
 * 
 * @author charles.zhang
 */
public class FileAccessException extends IOException {

    private static final long serialVersionUID = 2663198078357244592L;

    private String errcode;// 异常状态码

    public static final String FILE_NOT_FOUND = "404";

    public FileAccessException(String message) {
        super(message);
    }

    public FileAccessException(String message, Throwable exception) {
        super(message, exception);
        if (exception instanceof FileNotFoundException) {
            errcode = FILE_NOT_FOUND;
        }
    }

    public FileAccessException(String message, String statusCode) {
        super(message);
        this.errcode = statusCode;
    }

    public FileAccessException(String message, String statusCode, Throwable exception) {
        super(message, exception);
        this.errcode = statusCode;
    }

    public FileAccessException(Throwable exception) {
        super(exception);
        if (exception instanceof FileNotFoundException) {
            errcode = FILE_NOT_FOUND;
        }
    }

    public String getErrcode() {
        return errcode;
    }

    public void setErrcode(String errcode) {
        this.errcode = errcode;
    }
}
